package weatherwidget.isrefluxer.bird.com.birdweatherwidget.until;

import android.content.res.Resources;
import android.text.TextUtils;

import weatherwidget.isrefluxer.bird.com.birdweatherwidget.R;
import weatherwidget.isrefluxer.bird.com.birdweatherwidget.WidgetApplication;

/**
 * Created by Administrator on 2016/11/20 0020.
 */

public class Utils {
    public static String formatProvince(String province) {
        if (TextUtils.isEmpty(province)) {
            return null;
        }
        Resources resources = WidgetApplication.getInstance().getResources();
        if (province.endsWith(resources.getString(R.string.loc_province))
                || province.endsWith(resources.getString(R.string.loc_city))) {
            province = province.substring(0, province.length() - 1);
        } else if (province.startsWith(resources
                .getString(R.string.loc_xinjiang))) {
            return resources.getString(R.string.loc_xinjiang);
        } else if (province
                .startsWith(resources.getString(R.string.loc_xizang))) {
            return resources.getString(R.string.loc_xizang);
        } else if (province.startsWith(resources
                .getString(R.string.loc_ningxia))) {
            return resources.getString(R.string.loc_ningxia);
        } else if (province.startsWith(resources
                .getString(R.string.loc_neimenggu))) {
            return resources.getString(R.string.loc_neimenggu);
        } else if (province.startsWith(resources
                .getString(R.string.loc_guangxi))) {
            return resources.getString(R.string.loc_guangxi);
        } else if (province.startsWith(resources
                .getString(R.string.loc_xianggang))) {
            return resources.getString(R.string.loc_xianggang);
        } else if (province.startsWith(resources.getString(R.string.loc_aomen))) {
            return resources.getString(R.string.loc_aomen);
        }
        return province;
    }
}
